package com.youfang.sixthmedia.message.model;

import android.os.Parcel;
import android.os.Parcelable;

import com.gzit.store.Store;

public class ChatItem extends Store implements Comparable<ChatItem>,
		Parcelable, MessageBean {
	public static final int MY_MSG = 1;
	
	public static final ChatItem DUMY = new ChatItem();

	public Integer userid;// current logined user...
	public Integer mymsg = 0 ;//message from myself

	public Integer messageid;
	public Integer fromid;
	public String content;
	public Long time;
	public String fromusername;
	public String fromnickname;

	public ChatItem() {

	}

	public static final Parcelable.Creator<ChatItem> CREATOR = new Parcelable.Creator<ChatItem>() {
		public ChatItem createFromParcel(Parcel in) {
			return new ChatItem(in);
		}

		public ChatItem[] newArray(int size) {
			return new ChatItem[size];
		}
	};

	private ChatItem(Parcel in) {
		userid = in.readInt();
		mymsg = in.readInt();
		messageid = in.readInt();
		fromid = in.readInt();
		content = in.readString();
		time = in.readLong();
		fromusername = in.readString();
		fromnickname = in.readString();

	}

	@Override
	public int describeContents() {

		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {

		dest.writeInt(userid);
		dest.writeInt(mymsg);
		dest.writeInt(messageid);
		dest.writeInt(fromid);
		dest.writeString(content);
		dest.writeLong(time);
		dest.writeString(fromusername);
		dest.writeString(fromnickname);

	}

	@Override
	public int compareTo(ChatItem another) {
		if (this.time == another.time) {
			return 0;
		}

		return this.time > another.time ? 1 : -1;
	}

}
